﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace 省市级联.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            Business bus = new Business();
            bus.ProviceID = "16";
            bus.CityID = "167";
            bus.DistrictID = "1507";
            return View(bus);
        }
        [HttpPost]
        public JsonResult GetAddressSlect(int id, int type)
        {
            string option = string.Empty;

            switch (type)
            {
                case 0:
                    option = BusinessLogic.GetCity(id.ToString());
                    break;
                case 1:
                    option = BusinessLogic.GetDis(id.ToString());
                    break;

            }
            return Json(new { succ = true, str = option });
        }
        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            //return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
            return View();
        }
    }
}
